package com.dadi.broadcastdemo1;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

/**
 * created by 韦敏敏
 * on 2019/12/30
 */
public class MainFragment2 extends Fragment {
    private static final String ARG_PARAM1 = "param1";
    TextView logger = null;
    String myText = "";
    public MainFragment2() {
        // Required empty public
        myText = "";
    }
    public static MainFragment2  newInstance(String param1){
        MainFragment2 fragment2 = new MainFragment2();
        Bundle args = new Bundle();
        args.putString(ARG_PARAM1, param1);
        fragment2.setArguments(args);
        return fragment2;
    }

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if(getArguments() != null){
            myText = getArguments().getString(ARG_PARAM1);
        }
    }

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        // Inflater the layout for this fragment
        View myView = inflater.inflate(R.layout.layout_fragment2, container, false);
        logger = myView.findViewById(R.id.tvContent2);
        logger.setText(myText);
        myView.findViewById(R.id.btnSetAlarm).setOnClickListener(new View.OnClickListener(){

            @Override
            public void onClick(View view) {
                ((Test2Activity)getActivity()).setAlarm();
            }
        });
        return myView;
    }
}
